$(function(){
	post();
});
function post(){
	$.ajax({
		url:'consultType',
		type:'post',
		dataType:'json',
		success:function(data){
			show(data);
		}
	});
}
function show(data){
	var items;
	$.each(data,function(i,result){
		items="<li><a href='#' id='"+result['id']+"' onclick='getValue(this)'>"+result['type']+"</a></li>";
		$(".nav").append(items);
	});
}
function getValue(obj){
	var id=obj.id;
	$.ajax({
		url:'consultFileByType',
		type:'post',
		data:{typeId:id},
		dataType:'json',
		success:function(data){
			console.log(data);
			$("#table").bootstrapTable('load',data);
			$("#table").bootstrapTable({
				data:data,
				striped: true,
		        undefinedText: "-",
		        pagination: true, 
		        paginationLoop:true,
		        showToggle: true,
		        pageNumber: 1,
		        showPaginationSwitch:true, 
		        pageSize: 5,
		        search: true, 
		        idField: "id",
		        columns:[
		        	{
		        		title:'小说名称',
		        		field:'fileName',
		        		align:'center'
		        	},
		        	{
		        		title:'下载量',
		        		field:'downloadSum',
		        		align:'center'
		        	},
		        	{
		        		title:'操作',
		        		field:'id',
		        		align:'center',
		        		formatter:function(value){
		        			return "&nbsp;&nbsp;"+"<a class='btn btn-primary btn-xs' href='downloadFileById.do?j="+value+"'>下载</a>";
		        		}
		        	}
		        ]
			});
		}
	});
}